package com.zg.assistant.web;

import com.zg.assistant.req.GenerateQrCodeReq;
import com.zg.assistant.service.QrCodeService;
import com.zg.common.core.R;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
* @author zg
*/
@RestController
@RequiredArgsConstructor
public class QrCodeController {

	private final QrCodeService qrCodeService;

	/**
	 * 生成Base64格式的二维码
	 * @return Base64编码的二维码图片
	 */
	@PostMapping("/qrCode/generate")
	public R<String> generate(@RequestBody @Valid GenerateQrCodeReq param) {
		// 生成Base64格式的二维码
		String qrCodeBase64 = qrCodeService.createQrCodeBase64(param.getUuid());

		// 返回Base64格式的二维码
		return R.success(qrCodeBase64);
	}

}
